<?php
// +----------------------------------------------------------------------
// | 零云 [ 简单 高效 卓越 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.lingyun.net All rights reserved.
// +----------------------------------------------------------------------
// | Author: jry <598821125@qq.com>
// +----------------------------------------------------------------------
namespace Admin\Controller;

use Think\Page;

/**
 * 文章控制器
 * @author jry <598821125@qq.com>
 */
class InviteorderController extends AdminController
{
    /**
     * 默认方法
     * @author jry <598821125@qq.com>
     */
   

    public function index()
    {
        $uid = session('user_auth.uid');
        $user_group   = D('Admin/Access')->getFieldByUid($uid, 'group'); 
        // 搜索
        $keyword         = I('keyword', '', 'string');
        $condition       = array('like', '%' . $keyword . '%');
        //$map['name|mobile'] = array($condition, $condition, '_multi' => true);

        
        //$map['status'] = array('egt', '0'); // 禁用和正常状态
        
        $post_object   = D('Admin/Inviteorder');
        $p             = !empty($_GET["p"]) ? $_GET['p'] : 1;
        
        $map['A.name|A.mobile|B.title'] = array($condition, $condition, $condition, '_multi' => true);

        $map['A.ispay'] = 1;
        $map['A.status'] = array('egt', '0'); // 禁用和正常状态
        $data_list     = $post_object
            ->table('ly_admin_inviteorder A')
            ->join('LEFT JOIN ly_admin_invitation B ON A.inviteid=B.id')
            ->field('A.*,B.title')
            ->page($p, C('ADMIN_PAGE_ROWS'))
            ->where($map)
            ->order('A.id desc')
            ->select();

        $page = new Page(
            $post_object
            ->table('ly_admin_inviteorder A')
            ->join('LEFT JOIN ly_admin_invitation B ON A.inviteid=B.id')
            ->where($map)->count(),
            C('ADMIN_PAGE_ROWS')
        );

        

        $builder = new \Common\Builder\ListBuilder();
        
            $builder->setSearch('请输入姓名/手机号/邀请函', U('index'))
            ->addRightButton('forbid');
        //$('.item_atime').last().after($('.item_atime').clone(true));
            //$('.item_atime').after($('.item_atime').clone(true));
            //$('.item_atime:last').after($('.item_atime:last').clone(true));

        $builder->setMetaTitle('邀请函列表') // 设置页面标题
            ->addTableColumn('id', 'ID')
            
            ->addTableColumn('name', '姓名')
            //->addTableColumn('brand_name', '品牌名')
            ->addTableColumn('mobile', '电话')
            ->addTableColumn('title', '邀请函')
            ->addTableColumn('jointime', '体验时间','time')
            ->addTableColumn('joinnum', '参与人数')
            ->addTableColumn('realprice', '总票价')
            ->addTableColumn('create_time', '创建时间', 'time')
            ->addTableColumn('update_time', '更新时间', 'time')
            ->addTableColumn('ch', '客户渠道')
            ->addTableColumn('status', '状态', 'status')
            ->addTableColumn('right_button', '操作', 'btn')
            ->setTableDataList($data_list) // 数据列表
            ->setTableDataPage($page->show()) // 数据列表分页
            
            //->addRightButton('delete') // 添加删除按钮
            ->display();
    }

    
    
}
